/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2018
 */

package com.bm.console.business.impl;

import com.bm.console.business.WebChannelCounselorService;
import com.bm.console.pojo.WebChannelCounselor;
import com.bm.console.pojo.mapper.WebChannelCounselorMapper;
import com.sys.object.common.page.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class WebChannelCounselorServiceImpl implements WebChannelCounselorService {

	@Autowired
	WebChannelCounselorMapper webChannelCounselorMapper;

	@Override
	public PageBean queryPageList(WebChannelCounselor entity, PageBean page) throws Exception {
		int rowCount = webChannelCounselorMapper.selectByPageCount(entity);
		page.setRowCount(rowCount);
		entity.setOffset(page.getStartRow());
		entity.setLimit(page.getPerpage());
		page.setList(webChannelCounselorMapper.selectByPage(entity));
		return page;
	}

	public WebChannelCounselor queryByPrimaryKey(Integer id) throws Exception {
		return webChannelCounselorMapper.selectByPrimaryKey(id);
	}

	public int saveOrUpdate(WebChannelCounselor entity) throws Exception {
		if(entity.getId()!=null && entity.getId() > 0){
			return this.webChannelCounselorMapper.updateByPrimaryKeySelective(entity);
		}
		return this.webChannelCounselorMapper.insert(entity);
	}

	public int remove(Integer id) throws Exception {
		return this.webChannelCounselorMapper.deleteByPrimaryKey(id);
	}

	public int delete(Integer id) throws Exception {
		return this.webChannelCounselorMapper.deleteByPrimaryKey(id);
	}
	
	public int updateStatus(WebChannelCounselor entity) throws Exception{
		return this.webChannelCounselorMapper.updateByPrimaryKeySelective(entity);
	}

	public int updateStatus(String status, String[] ids)
			throws Exception {
		
		return 0;
	}


    @Override
    public List<WebChannelCounselor> selectByAll() {
        return webChannelCounselorMapper.selectByAll();
    }
}
